from datetime import datetime
import time
import random
 
while True:
    # 获取当前时间
    now = datetime.now()
    # 获取1-3的随机整数
    sleep_time = random.randint(1, 3)
    print("当前时间：" + str(now) + "；睡眠时间：" + str(sleep_time) + "秒")
    # 线程睡眠
    time.sleep(sleep_time)
